import { visibleRect, color } from '../../creator';
const {ccclass, property} = cc._decorator;

@ccclass
export default class Helloworld extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property
    text: string = 'hello';

    start () {
        //this.node.children[0].opacity = 1
        this.addListener();
    }

    addListener(){
        const init_point = cc.view.getVisibleSize()
        this.node.on("touchmove",function(e){
            //console.log(e)
            this.node.children[0].x = e.currentTouch._point.x -init_point.width/2
            this.node.children[0].y = e.currentTouch._point.y-init_point.height/2
        },this)
        this.node.on("touchstart",function(e){
           // console.log(this.node.children[0])
            //console.log(e)
             this.node.children[0].active  = true
            //this.node.children[0].opacity = 0.5
            this.node.children[0].x =e.currentTouch._point.x -init_point.width/2 
            this.node.children[0].y =e.currentTouch._point.y -init_point.height/2
        },this)
        this.node.on("touchend",function(e){
            //console.log(e)
            //this.node.children[0].opacity = 100
             this.node.children[0].active  = false
           // this.node.children[0].x =e.currentTouch._point.x -init_point.width/2 
            //this.node.children[0].y =e.currentTouch._point.y -init_point.height/2
        },this)
    }
}
